﻿using FPSO.Models.Constant;
using FPSO.Models.TagMapping;
using Microsoft.Practices.Prism.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FPSO.Models.ViewModel.Controls
{

    public class TankViewModel : NotificationObject
    {
        public TankViewModel(string tankId, double totalVolume)
        {
            volume = 0;
            level = 0;
            rate = 0;
            this.totalVolume = totalVolume;
            TankId = tankId;
        }

        private double volume;
        private double level;
        private double rate;
        private double totalVolume;

        public string TankId { get; private set; }

        /// <summary>
        /// 当前容量
        /// </summary>
        [FieldMapper("VOLM", TypeCode.Int32, TankConstant.CALC_PARAM)]
        public double Volume
        {
            get { return volume; }
            set
            {
                volume = value;
                this.RaisePropertyChanged("Volume");
            }
        }

        /// <summary>
        /// 液位高
        /// </summary>
        [FieldMapper("LEVEL", TypeCode.Int32, TankConstant.TANKLEVEL_PARAM)]
        public double Level
        {
            get { return level; }
            set
            {
				if (value > 0)
				{
					double a = 0;
				}
				level = value;
                this.RaisePropertyChanged("Level");
            }
        }

        /// <summary>
        /// 速率
        /// </summary>
        [FieldMapper("RATE", TypeCode.Int32, TankConstant.CALC_PARAM)]
        public double Rate
        {
            get { return rate; }
            set
            {
                rate = value;
                this.RaisePropertyChanged("Rate");
            }
        }

        /// <summary>
        /// 舱室总容量
        /// </summary>
        public double TotalVolume
        {
            get { return totalVolume; }
            set
            {
                totalVolume = value;
                this.RaisePropertyChanged("TotalVolume");
            }
        }
    }
}
